package com.rul.mars.shop.controller;

import com.rul.mars.common.api.CommonResult;
import com.rul.mars.mbg.domain.ShopApplicationParam;
import com.rul.mars.mbg.domain.ShopDetail;
import com.rul.mars.mbg.model.Shop;
import com.rul.mars.shop.service.ShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 店铺服务接口
 *
 * @author RuL
 */
@Api(tags = "ShopController", description = "用户服务接口")
@RestController
@RequestMapping(path = "/shop")
public class ShopController {

    @Autowired
    private ShopService shopService;

    /**
     * 店铺申请入驻
     *
     * @param param 申请参数
     * @return 操作结果
     */
    @ApiOperation("店铺申请入驻")
    @PostMapping("/applyForEnter")
    public CommonResult applyForEnter(@RequestBody ShopApplicationParam param) {
        if (shopService.applyForEnter(param)) {
            return CommonResult.success("申请成功");
        }
        return CommonResult.failed("申请失败");
    }


    /**
     * 店铺入驻审核状态查询
     *
     * @return 店铺审核状态
     */
    @ApiOperation("店铺入驻审核状态查询")
    @GetMapping("/reviewStatus")
    public CommonResult<ShopDetail> reviewStatus() {
        ShopDetail shopDetail = shopService.reviewStatus();
        return CommonResult.success(shopDetail);
    }

    /**
     * 店铺详情查询
     *
     * @param id 店铺ID
     * @return 店铺详细信息
     */
    @ApiOperation("店铺详情查询")
    @GetMapping("/detail/{id}")
    public CommonResult<ShopDetail> detail(@PathVariable(value = "id") Long id) {
        ShopDetail shopDetail = shopService.detail(id);
        return CommonResult.success(shopDetail);
    }

    /**
     * 查询当前店铺信息
     *
     * @return 当前店铺信息
     */
    @ApiOperation("当前店铺信息")
    @GetMapping("/current")
    public Shop current() {
        return shopService.current();
    }


}
